package me.zhengjie.hr.employeestate.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.hr.employeebase.domain.EmployeeBase;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @author ZGZ
* @date 2020-04-15
*/
@Entity
@Data
@Table(name="employee_state")
public class EmployeeState implements Serializable {

    /** 行键 */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    /** 人员id */
//    @Column(name = "emp_id")
//    private Integer empId;
//    @OneToOne
//    @JoinColumn(name = "emp_id")
//    private EmployeeBase empId;
    @Column(name = "emp_id")
    private Integer empId;
    @OneToOne
    @JoinColumn(name = "emp_id", insertable = false, updatable = false)
    private EmployeeBase employeeBase;

    /** 地点 */
    @Column(name = "business_add")
    private String businessAdd;

    /** 开始时间 */
    @Column(name = "start_time")
    private Timestamp startTime;

    /** 结束时间 */
    @Column(name = "end_time")
    private Timestamp endTime;

    /** 事由 */
    @Column(name = "reason")
    private String reason;

    /** 类型（出差/休假/病假/事假） */
    @Column(name = "type")
    private String type;

    public void copy(EmployeeState source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}